#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/11/23
# @Author   :Changshu
# @File     :Exercise_476.py
# 476. 数字的补数

def findComplement(num: int) -> int:
	n=num
	c=0
	while n>0:
		n=n>>1
		c=(c<<1)+1
	return num^c

if __name__ == '__main__':
	num=1
	print(findComplement(num))